<!DOCTYPE html>
<html>
<head>
    <title><?php echo $title; ?> // Admin</title>
    <link rel="stylesheet" href="<?php echo site_url('public/css/style.css'); ?>" />
    <script src="<?php echo site_url('public/js/jquery.js'); ?>"></script>
	<script src="<?php echo site_url('public/js/alert.js'); ?>"></script>
	
	<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body>
	<div class="container" style="width: 450px; margin-top: 80px;">
		<div class="page-header">
			<h1>CMS <small>San Miguel Purefoods</small></h1>
		</div>

		<?php echo form_open('', array('autocomplete' => 'off')); ?>
			<div class="clearfix">
				<label>Email</label>
				<div class="input">
					<input type="text" name="email" />
				</div>
			</div>
			<div class="clearfix">
				<label>Password</label>
				<div class="input">
					<input type="password" name="password" />
				</div>
			</div>
			<div class="actions">
				<button type="submit" class="btn primary">Login</button>
				<span class="btn">Forgot Password</span>
			</div>
		</form>

		<script>
			$('form').submit(function() {
				
				var form = $(this);
				
				form.find('.alert-message').remove();
				form.find('.btn.primary').addClass('disabled').html('Loading&hellip;');
				
				$.ajax({
					type: form.attr('method'),
					url: form.attr('action'),
					data: form.serialize(),
					dataType: 'json',
					success: function(data)
					{
						form.find('.btn.primary').removeClass('disabled').text('Login');
						
						if (data.success == true)
						{
							if (data.action == 'redirect') window.location = data.url;
						}
						else
						{
							var div = $('<div />').addClass('alert-message block-messag1e error');
							div.append($('<span />').addClass('close').html('&times;'));
							div.append(data.errors)
							div.hide().prependTo(form).fadeIn();
							
							form.find('input[name="password"]').val('');
						}
					}
				});
				
				return false;
			});
		</script>
	</div>
</body>
</html>